<!-- pass a variable to included page -->
<%@ page import="bcared.*" %>
<%@ page import="java.text.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.sql.*" %>
<% 
   String today = null;
   Today t = new Today();
   today = t.getToday();
   request.setAttribute("picture","Customer");
   request.setAttribute("title", "Customer Home"); 
   request.setAttribute("header", "Welcome " + 
   		session.getAttribute("firstname") + " " + 
   		session.getAttribute("lastname") + " from " + 
   		session.getAttribute("customername") + " : Today is " + today); 
   		
	ResultSet rs = null;
	CallableStatement csmt = null;
	PreparedStatement ps = null;
	OraDB myDB = new OraDB();
	
   	
   	myDB.createConnection();
   	String myQuery = "SELECT * FROM serviceordertype ORDER BY serviceTypeDescription ASC";
   	ps = myDB.conn.prepareStatement(myQuery);
	rs = ps.executeQuery();
	
	ArrayList<Integer> serviceOrderTypeID = new ArrayList<Integer>();
	ArrayList<String> serviceTypeDescription = new ArrayList<String>();
   	
   	while (rs.next()) {
   		serviceOrderTypeID.add(rs.getInt("serviceOrderTypeID"));
   		serviceTypeDescription.add(rs.getString("serviceTypeDescription"));
   	}
   		
 %>
 <%@ include file="header.jsp"%>
 
 <TD width="850" vAlign="top">

<% 
	Equipment equip = new Equipment(Integer.parseInt(request.getParameter("equipmentID")));
	Customer cust = new Customer(Integer.parseInt(request.getParameter("customerID")));
%>
	<table width="100%" border=0 cellpadding=3 cellspacing=3>
		<tr>
			<td width="14%" style="font-weight: bold;">Product Name:</td>
			<td><%=equip.getProductName() %></td>
			<td width="14%" style="font-weight: bold;">Serial Number</td>
			<td><%=equip.getSerialNumber() %></td>
		</tr>
		
		<tr>
			<td width="14%" style="font-weight: bold;">Address:</td>
			<td><%=equip.getAddress1() %></td>
			<td width="14%" style="font-weight: bold;">City, State</td>
			<td><%=equip.getCity() + ", " + equip.getState() %></td>
		</tr>
		<tr>
			<td width="14%" style="font-weight: bold;">In Service Date:</td>
			<td><%=equip.getInServiceDate() %></td>
			<td width="14%" style="font-weight: bold;">Out Service Date:</td>
			<td><%=equip.getOutServiceDate() %></td>
		</tr>
	</table>
	
	<form method="post" action="NewServiceOrderInsert.jsp">
		<table>
			<tr>
				<td>Contact Name:</td>
				<td><input type="text" name="contactName" value="<%=cust.getFirstname() + " " + cust.getLastname()%>" /></td>
			</tr> 
			<tr>
				<td>Contact Phone:</td>
				<td><input type="text" name="contactPhone" value="<%=cust.getPhone()%>" /></td>
			</tr>
			<tr>
				<td>Contact Email:</td>
				<td><input type="text" name="contactEmail" value="<%=cust.getEmail()%>" /></td>
			</tr>
			<tr>
				<td>Problem:</td>
				<td>
					<select name="serviceOrderTypeID">
						<%
							for (int i = 0; i < serviceOrderTypeID.size(); i++) {
								%>
								<option value="<%=serviceOrderTypeID.get(i) %>"><%=serviceTypeDescription.get(i)%></option>
								<%
							}
						%>
					</select>
				</td>
			</tr>
			<tr>
				<td>Problem Description:</td>
				<td><textarea name="problemDesc" col="80" row="10"></textarea></td>
			</tr>
			<tr>
				<td><input type="checkbox" name="lifeInDanger" value=1 />Patient on table?<br /></td>
			</tr>
		</table>
		<input type="hidden" name="equipmentID" value="<%=equip.getEquipmentID()%>"/>
		<input type="hidden" name="customerID" value="<%=Integer.parseInt(request.getParameter("customerID"))%>"/>
	
		<input type="submit" name="submit" value="Submit"/>
	</form>

</td>
<%@ include file="footer.jsp"%>